import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.Random;

/**
 * Created by dengpan on 14-10-25.
 */
public class MyFile {
    private static final int MAX = 10000;

    private static final Random sRandom = new Random();

    private static String one_mil() {
        StringBuilder builder = new StringBuilder(MAX * 100);
        for(int i = 0; i < MAX; i++) {
            builder.append(sRandom.nextInt(10000) + 1);
            builder.append('\t');
            builder.append(sRandom.nextInt(10000) + 1);
            builder.append('\t');
            builder.append(sRandom.nextInt(10000) + 1);
            builder.append('\t');
            builder.append(sRandom.nextInt(10000) + 1);
            builder.append('\t');
            builder.append(sRandom.nextInt(10000) + 1);
            builder.append('\n');
        }

        return builder.toString();
    }

    private static void create_one(File dir, int filename) throws IOException {
        File out = new File(dir, "r_java_" + filename);
        if (!out.exists())
            out.createNewFile();
        String content = one_mil();
        FileOutputStream os = new FileOutputStream(out);
        os.write(content.getBytes());
        os.close();
    }

    public static void main(String[] args) {
        File dir = new File("out");
        if (!dir.exists())
            dir.mkdirs();
        for (int i = 0; i < MAX; i++) {
            try {
                create_one(dir, i);
            } catch (IOException e) {
                e.printStackTrace();
            }
        }
    }
}
